<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
                <router-link :to="'/home/newsinfo/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <h1>{{ item.title }}</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间：{{ item.add_time | dateFormat }}</span>
                            <span>点击：{{ item.click }}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>


<script>
// http://www.liulongbin.top:3005/api/getnew
import Toast from 'mint-ui'

export default {
    data() {
        return {
            newslist: [
                {   
                    id: 0,
                    title: '巴黎圣母院惨遭火灾，有人痛心祈祷，有人却骂“活该”？',
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8580355543/0",
                   
                },
                {   
                    id: 1,
                    title: "许志安与郑秀文的感情，分分合合历经28年，犹如一场爱情马拉松",
                    add_time: "2019-04-17 01:12:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8275537182/0",
                },
                {
                    id: 2,
                    title: "大唐芙蓉园风车满园 春风里转出浪漫童年记忆",
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8594408780/0",
                },
                {
                    id: 3,
                    title: "率先跨季穿上凉鞋的三里屯美女有多美",
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8593999186/0",
                },
                {
                    id: 4,
                    title: '巴黎圣母院惨遭火灾，有人痛心祈祷，有人却骂“活该”？',
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8580355543/0",
                },
                {
                    id: 5,
                    title: "许志安与郑秀文的感情，分分合合历经28年，犹如一场爱情马拉松",
                    add_time: "2019-04-17 01:12:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8275537182/0",
                },
                {
                    id: 6,
                    title: "大唐芙蓉园风车满园 春风里转出浪漫童年记忆",
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8594408780/0",
                },
                {
                    id: 7,
                    title: "率先跨季穿上凉鞋的三里屯美女有多美",
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8593999186/0",
                },
                {
                    id: 8,
                    title: '巴黎圣母院惨遭火灾，有人痛心祈祷，有人却骂“活该”？',
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8580355543/0",
                },
                {
                    id: 9,
                    title: "许志安与郑秀文的感情，分分合合历经28年，犹如一场爱情马拉松",
                    add_time: "2019-04-17 01:12:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8275537182/0",
                },
                {
                    id: 10,
                    title: "大唐芙蓉园风车满园 春风里转出浪漫童年记忆",
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8594408780/0",
                },
                {
                    id: 11,
                    title: "率先跨季穿上凉鞋的三里屯美女有多美",
                    add_time: "2019-04-16 00:00:00",
                    click: 5,
                    img_url: "https://inews.gtimg.com/newsapp_match/0/8593999186/0",
                },
            ]
        }
    },
    methods: {
        // 获取新闻列表
        getNewsList(){
            this.$http.get("api/newslist").then(result => {
                console.log("11" + result.body)
                if (result.body.status === 0) {
                    console.log("OK")
                    // this.newslist = resuly.body.message
                } else {
                    Toast("获取新闻列表失败！")
                }
            })
        }
    },
    created() {
        this.getNewsList()
    },
}
</script>


<style lang="scss" scoped>
    .mui-table-view{
        li{
            h1{
                font-size: 14px;
            }
            .mui-ellipsis{
                font-size: 12px;
                color: #226aff;
                display: flex;
                justify-content: space-between;     // 两端对齐
            }
        }
    }
</style>
